# imports from custom library
import sys
sys.path.append('../../')
import matplotlib.pyplot as plt
from mlrefined_libraries import convnets_library as convlib
import autograd.numpy as np
import pandas as pd
import cv2
#this is needed to compensate for matplotlib notebook's tendancy to blow up images when plotted inline
%matplotlib notebook
from matplotlib import rcParams
rcParams['figure.autolayout'] = True
%load_ext autoreload
%autoreload 2
# read Trump's job approval data (from http://www.presidency.ucsb.edu/data/popularity.php)
df = pd.read_csv("../../mlrefined_datasets/nonlinear_superlearn_datasets/job_approval_data.csv",
delim_whitespace = True, header=None)
# extract disapproval ratings
y = np.asarray(df[2])
# reverse the order of data (to be ascending in time)
y = y[::-1]
# create an instance of the visualizer with this input sequence
conv_viz = convlib.conv_1d_viz.visualizer(y = y)
# run the visualizer for our chosen input sequence
conv_viz.draw_it(num_frames=100)
img = cv2.imread('cartman.jpg', 0)
img = img[200:600,500:900]
# add noise
#sig = 100
#img = img + np.round(sig*np.random.randn(np.size(img,0),np.size(img,1))).astype(int)
# create an instance of the visualizer with this function
conv2_viz = convlib.conv_2d_viz.visualizer(img = img)
# run the visualizer for our chosen input function
conv2_viz.draw_it(num_frames=50)
img = cv2.imread('cartman.jpg', 0)
img = img[200:600, 500:900]
edges = cv2.Canny(img,1,1000)
plt.subplot(121),plt.imshow(img,cmap = 'gray')
plt.subplot(122),plt.imshow(edges,cmap = 'gray')
plt.show()
# create an instance of the visualizer with this function
edge = convlib.edge_viz.visualizer(img = img)
# run the visualizer for our chosen input function
edge.draw_it(num_frames = 500)